package com.pllandxzx.controller;

import com.pllandxzx.dto.ResponseDTO;
import com.pllandxzx.service.AdminService;
import com.pllandxzx.vo.AdminVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "管理员模块")
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @Operation(summary = "登录", description = "管理员登录，生成token")
    @PostMapping("/login")
    public ResponseDTO login(@RequestBody AdminVo adminVo, HttpServletRequest request)
    {
        return adminService.login(adminVo,request);
    }

    @Operation(summary = "验证码", description = "生成管理员登录的验证码")
    @GetMapping("/capture")
    public void capture(HttpServletResponse response, HttpSession session) {
        adminService.capture(response, session);
    }
}
